
local blockScale =2
local FrameLoader = require("Utils.FrameLoader")

local Consts =require("Data.Consts")
local PrefabFactory =require("Utils.PrefabFactory")
G = {}
G.frameLoader = FrameLoader.new(1, 1) -- 分帧加载器
G.prefabFactory = PrefabFactory.new()
G.tickables = {G.frameLoader}
local xCount = 5
local yCount = 5
local zCount = 5  



local blockSize = 2

function generataBlock(x,y,z)
    local obstacle = GameAPI.create_obstacle(1073741871, math.Vector3(x, y, z), math.Quaternion(0, 0, 0),
    math.Vector3(2, 2, 2), nil)
end
for k = 1, yCount do
    for i = 1, xCount do -- 10/2=5个方块
        for j = 1, zCount do
            local x = (i - 1) * blockSize + 1 -- 1, 3, 5, 7, 9
            local y = (k - 1) * blockSize + 1 -- 1, 3, 5, 7, 9
            local z = (j - 1) * blockSize + 1 -- 1, 3, 5, 7, 9
            G.prefabFactory:createPrefabWithCb(
		-- 预设类型
		Consts.PrefabType.UNIT_OBSTACLE,
		-- 预设ID
		1073741871,
		-- 创建位置
		math.Vector3(x, -y, z),
		-- 创建旋转
		math.Quaternion(0, 0, 0),
		-- 创建缩放
		math.Vector3(2, 2, 2),
		-- 创建成功后的回调
		function(unit)
			
		end
)

          
           
        end
    end
end


function G.addTickable(obj)
    assert(obj.update)
    table.insert(G.tickables, obj)
end

-- 移除可更新对象的函数
function G.removeTickable(obj)
    for i, v in ipairs(G.tickables) do
        if v == obj then
            table.remove(G.tickables, i)
            break
        end
    end
end

-- 定义每帧更新前的处理函数
local function onPreTick(_)
    for _, v in ipairs(G.tickables) do
        v:update()
    end
end

-- 定义每帧更新后的处理函数（当前为空）
local function onPostTick()
end

-- 设置帧更新处理器
LuaAPI.set_tick_handler(onPreTick, onPostTick)


























